﻿' 
' Copyright (C) 2014 Infinity CCS Ltd (http://www.infinityccs.com/)
' Copyright (C) 2008 Sasa Coh <sasacoh@gmail.com>
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program.  If not, see <http://www.gnu.org/licenses/>. 
'/


Imports System
Imports System.Collections.Generic
Imports Infinity.pjsipNET.Common.Config

Namespace Common
  ''' <summary>
  ''' Abstract class for registration handling. Contains API method to register accounts and 
  ''' event for registration state change notification.
  ''' </summary>
  Public MustInherit Class IRegistrar
#Region "Properties"
    Private _config As IConfigurator = New NullConfigurator()
    Public Property Config As IConfigurator
      Get
        Return _config
      End Get
      Set(value As IConfigurator)
        _config = value
      End Set
    End Property
#End Region

#Region "Public Methods"
    ''' <summary>
    ''' Register accounts. Account data taken from Config property
    ''' </summary>
    ''' <returns></returns>
    Public MustOverride Function registerAccounts() As Integer

    ''' <summary>
    ''' Unregister all accounts
    ''' </summary>
    ''' <returns></returns>
    Public MustOverride Function unregisterAccounts() As Integer

#End Region

#Region "Events"
    ''' <summary>
    ''' Event AccountStateChanged informs clients about account state changed
    ''' </summary>
    Public Event AccountStateChanged(accountName As String, accStatus As Integer, accStatusText As String)

    ''' <summary>
    ''' AccountStateChanged event trigger by VoIP stack when registration state changed
    ''' </summary>
    Protected Sub BaseAccountStateChanged(accountName As String, accStatus As Integer, accStatusText As String)
      RaiseEvent AccountStateChanged(accountName, accStatus, accStatusText)
    End Sub
#End Region
  End Class
End Namespace